package com.example.shortlink.dao.mapper;

import com.example.shortlink.dao.entity.LinkNetworkStats;
import com.mybatisflex.core.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;

public interface LinkNetworkStatsMapper extends BaseMapper<LinkNetworkStats> {

    @Insert("<script> " +
            "INSERT INTO " +
            "t_link_network_stats " +
            "(" +
            "full_short_url, " +
            "gid, " +
            "date, " +
            "cnt, " +
            "network, " +
            "create_time, " +
            "update_time, " +
            "del_flag" +
            ") " +
            "VALUES" +
            "( " +
            "#{linkNetworkStats.fullShortUrl}, " +
            "#{linkNetworkStats.gid}, " +
            "#{linkNetworkStats.date}, " +
            "#{linkNetworkStats.cnt}, " +
            "#{linkNetworkStats.network}, " +
            "NOW(), " +
            "NOW(), " +
            "0" +
            ") " +
            "ON DUPLICATE KEY UPDATE cnt = cnt +  #{linkNetworkStats.cnt} " +
            "</script>")
    void shortLinkNetworkState(@Param("linkNetworkStats") LinkNetworkStats linkNetworkStatsDO);
}